#ifndef _PLUGIN_API_MGR_H_
#define _PLUGIN_API_MGR_H_

#include <map>
#include "Exchange.h"
#include "DataTypes.h"
#include <boost/shared_ptr.hpp>
#include <boost/filesystem.hpp>
#include <boost/dll.hpp>
#include <boost/noncopyable.hpp>

#include "PluginApi.h"

class BOOST_SYMBOL_EXPORT PluginApiMgr:public boost::noncopyable
{
public:
	~PluginApiMgr(void);
public:
	//加载插件
	size_t LoadPlugins(const std::string& pluginDir=".");
	//执行所有插件;
	size_t ExecutePlugins();
	//接口函数;
	boost::shared_ptr<PluginApi> GetPluginApi(const std::string& id);

	//创建交易接口并登录;
	boost::shared_ptr<PluginApi> CreatePluginApi(const std::string& pluginPath);

	std::map<std::string, boost::shared_ptr<PluginApi> >& GetPluginApis();

	void Release();

protected:
	//依然是单例;
	PluginApiMgr(void) BOOST_NOEXCEPT;

public:
	static PluginApiMgr& GetInstance();
protected:
	//接口;
	std::map<std::string, boost::shared_ptr<PluginApi> > m_mapPluginApis;
	//库管理;
	std::map<boost::filesystem::path, boost::shared_ptr<boost::dll::shared_library> > m_ApiLibs;
};
#endif
